package itcz.example.pattern.create_action.factory.simple_factory;

/**
 * @ClassName: SimpleCoffeeFactory
 * @Author: ITCZ
 * @Date: 2025-04-26
 * @Description: 简单工厂模式
 */
public class SimpleCoffeeFactory {
    public Coffee createCoffee(String type) {
        Coffee coffee = null;
        if ("american".equals(type)) {
            coffee = new AmericanCoffee();
        } else if ("latte".equals(type)) {
            coffee = new LatteCoffee();
        } else {
            throw new RuntimeException("对不起，您点的咖啡没有");
        }
        return coffee;
    }
}
